<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="./../jquery-easyui-1.6.6/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="./../jquery-easyui-1.6.6/themes/icon.css">
    <script type="text/javascript" src="./../jquery-easyui-1.6.6/jquery.min.js"></script>
    <script type="text/javascript" src="./../jquery-easyui-1.6.6/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="./../js/jquery.serializejson.min.js"></script>
    <script type="text/javascript" src="../js/xheditor-1.2.2/xheditor-1.2.2.min.js"></script>
    <script type="text/javascript" src="../js/xheditor-1.2.2/xheditor_lang/zh-cn.js"></script>
    <link rel="stylesheet" href="release.css" />
</head>

<body>

    <div id="dlg" title="Basic Dialog" style="width:800px;height:400px;padding:10px">
        <form id="ff" method="post">
            <div style="margin-bottom:20px">
                <input class="easyui-textbox title" name="title" label="新闻标题:">
            </div>
            <div style="margin-bottom:20px">
                <select class="easyui-combobox classes" name="cate" label="新闻类别:"><option value="国内">国内</option><option value="国际">国际</option><option value="军事">军事</option><option value="娱乐">娱乐</option><option value="体育">体育</option><option value="社会">社会</option><option value="财经">财经</option><option value="互联网">互联网</option><option value="科技">科技</option></select>
            </div>
            <div style="margin-bottom:20px">
                新闻属性: <input type="checkbox" name="property" value="头条" class="property"> 头条 <input type="checkbox" value="热点" name="property"> 热点
            </div>
            <div style="margin-bottom:20px">
                <span>发布时间: </span>
                <input class="times" name="time" style="color: black;" id="time1" label="发布时间:">
            </div>
            <div style="margin-bottom:20px">
                <span class="ti">新闻内容:</span>
                <textarea cols="120" rows="30" name="content" class="details" id="content"></textarea>
            </div>
        </form>
        <div style="text-align:center;padding:5px 0">
            <a href="javascript:void(0)" class="easyui-linkbutton but" onclick="submitForm()" style="width:80px">Submit</a>
            <a href="javascript:void(0)" class="easyui-linkbutton but" onclick="clearForm()" style="width:80px">Clear</a>
        </div>
    </div>
    <script>
        function mytime() {
            var a = new Date();
            var c = a.toLocaleDateString();
            $('.times').val(c);

        }
        setInterval(function() {
            mytime()
        }, 1000);
        // function localDate() {
        //     const d = new Date();
        //     console.log(d);
        //     // d.setMinutes(d.getMinutes() - d.getTimezoneOffset());
        //     var c = d.toISOString();
        //     $('.times').val(c);
        //  
        // }
        // setInterval(function() {
        //     localDate()
        // }, 1000);
    </script>
    <script type="text/javascript">
        $(pageInit);

        function pageInit() {
            $('#content').xheditor({
                html5Upload: false,
                upMultiple: '1',

                upLinkUrl: "upload.php",
                upLinkExt: "zip,rar,txt",

                upImgUrl: "http://localhost:8888/news/uploadFile/Images",
                upImgExt: "jpg,jpeg,gif,png",

                upFlashUrl: "upload.php",
                upFlashExt: "swf",
                upMediaUrl: "upload.php",
                upMediaExt: "wmv,avi,wma,mp3,mid"
            });
        }
    </script>

    <script>
        function submitForm() {
            $('#ff').form('submit', {
                onSubmit: function() {
                    if ($(this).form('enableValidation').form('validate')) {
                        // 表单验证成功
                        var formData = $('#ff').serializeJSON();

                        $.messager.confirm('提示', '你确定发布这条新闻?', function(r) {
                            if (r) {
                                $.ajax({
                                    url: `${parent.globalUrl}release/data/`,
                                    type: 'post',
                                    data: formData,
                                }).then(res => {
                                    $('#dlg').datagrid('reload');
                                })
                                $('#ff').form('clear');
                            }
                        });
                    }
                    return false;
                }
            });

        }

        function clearForm() {
            $('#ff').form('clear');
        }
    </script>
</body>

</html>